package com.example.studywords.bean;

import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.ForeignKey;
import androidx.room.Ignore;
import androidx.room.Index;
import androidx.room.PrimaryKey;

import com.example.studywords.utils.DateUtil;

/**
 * 记录单词信息,correctNum表示答对次数,lastStudyTime表示上次学习时间
 */
@Entity(tableName = "word_info",
    foreignKeys = {@ForeignKey(entity = WordBean.class,parentColumns = "wordId",childColumns = "infoChildWordId",onDelete = ForeignKey.CASCADE)},
    indices = {@Index(value = "infoChildWordId",unique = true)})
public class WordInfoBean {
    @Ignore
    public WordInfoBean(int infoChildWordId,String wordNote) {
        this.infoChildWordId = infoChildWordId;
        this.wordNote = wordNote;
        //新建时也应有个日期
        lastStudyTime = DateUtil.getCurrentDate();
    }

    @Ignore
    public WordInfoBean(int infoChildWordId) {
        this.infoChildWordId = infoChildWordId;
        //新建时也应有个日期
        lastStudyTime = DateUtil.getCurrentDate();
    }

    public WordInfoBean() {
    }

    public int getWordInfoId() {
        return wordInfoId;
    }

    public void setWordInfoId(int wordInfoId) {
        this.wordInfoId = wordInfoId;
    }

    public int getInfoChildWordId() {
        return infoChildWordId;
    }

    public void setInfoChildWordId(int infoChildWordId) {
        this.infoChildWordId = infoChildWordId;
    }

    public int getCorrectNum() {
        return correctNum;
    }

    public void setCorrectNum(int correctNum) {
        this.correctNum = correctNum;
    }

    public String getLastStudyTime() {
        return lastStudyTime;
    }

    public void setLastStudyTime(String lastStudyTime) {
        this.lastStudyTime = lastStudyTime;
    }

    public String getWordNote() {
        return wordNote;
    }

    public void setWordNote(String wordNote) {
        this.wordNote = wordNote;
    }
    @PrimaryKey(autoGenerate = true)
    private int wordInfoId;
    private int infoChildWordId;
    @ColumnInfo(defaultValue = "0")
    private int correctNum;
    private String lastStudyTime;
    private String wordNote;
}
